import { createSlice } from '@reduxjs/toolkit'
// Define the initial state using that type
const initialState = {
  list: [],
  version: Date.now(),
  currentCase: null,
  currentPerson: null,
  mine: null,
  loadMoreVersion: Date.now()
}

export const chartSlice = createSlice({
  name: 'chart',
  // `createSlice` will infer the state type from the `initialState` argument
  initialState,
  reducers: {
    setList: (state, action) => {
      state.list = action.payload
    },
    setVersion: (state, action) => {
      state.version = action.payload
    },
    setCurrentCase: (state, action) => {
      state.currentCase = action.payload
    },
    setCurrentPerson: (state, action) => {
      state.currentPerson = action.payload
    },
    setMine: (state, action) => {
      state.mine = action.payload
    },
    setLoadMoreVersion: (state, action) => {
      state.loadMoreVersion = action.payload
    }
  },
})

export const { setList, setVersion, setCurrentCase, setCurrentPerson, setMine, setLoadMoreVersion } = chartSlice.actions

export default chartSlice.reducer